package com.huanhuan.index;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RequestOptions;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.client.indices.GetIndexRequest;
import org.elasticsearch.client.indices.GetIndexResponse;


public class ESTest_Client_Index_Search {
    public static void main(String[] args) throws Exception {

        final String hostname = "localhost";
        final int port = 9200;
        final String schema = "http";
        HttpHost httpHost = new HttpHost( hostname, port, schema );

        //创建ES环境
        RestHighLevelClient client =
                new RestHighLevelClient( RestClient.builder( httpHost ) );


        //查看索引操作
        // 查询索引 - 请求对象
        GetIndexRequest request = new GetIndexRequest("huan");


        GetIndexResponse response = client.indices().get( request, RequestOptions.DEFAULT );

        System.out.println( response.getAliases() );
        System.out.println( response.getMappings() );
        System.out.println( response.getSettings());


    }
}
